#include "sort.h"

void SelectSort(vector<int>& vc){
  int left = 0;
  int right = vc.size()-1;

  while(left < right)
  {
    int maxi = left;
    int mini = left;
    
    for(int i = left+1; i<=right; ++i)
    {
      if(vc[i] > vc[maxi])
      {
        maxi = i;
      }
      if(vc[i] < vc[mini])
      {
        mini = i;
      }
    }

    swap(vc[mini], vc[left]);
    if(maxi == left)
    {
      maxi = mini;
    }
    swap(vc[maxi], vc[right]);

    ++left;
    --right;
  }
}
